Пример #1
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            if (writer.SerializeTo != SerializeTo.SourcePages)
            {
                writer.Write(Data.Columns);
                writer.Write(Data.Rows);
                writer.Write(Data.Cells);
            }
            else
            {
                RefreshTemplate(true);
            }

            base.Serialize(writer);
            CrossViewObject c = writer.DiffObject as CrossViewObject;

            if (CubeSource != c.CubeSource)
            {
                writer.WriteRef("CubeSource", CubeSource);
            }
            if (ColumnDescriptorsIndexes != c.ColumnDescriptorsIndexes)
            {
                writer.WriteStr("ColumnDescriptorsIndexes", ColumnDescriptorsIndexes);
            }
            if (RowDescriptorsIndexes != c.RowDescriptorsIndexes)
            {
                writer.WriteStr("RowDescriptorsIndexes", RowDescriptorsIndexes);
            }
            if (ColumnTerminalIndexes != c.ColumnTerminalIndexes)
            {
                writer.WriteStr("ColumnTerminalIndexes", ColumnTerminalIndexes);
            }
            if (RowTerminalIndexes != c.RowTerminalIndexes)
            {
                writer.WriteStr("RowTerminalIndexes", RowTerminalIndexes);
            }
            if (ShowTitle != c.ShowTitle)
            {
                writer.WriteBool("ShowTitle", ShowTitle);
            }
            if (ShowXAxisFieldsCaption != c.ShowXAxisFieldsCaption)
            {
                writer.WriteBool("ShowXAxisFieldsCaption", ShowXAxisFieldsCaption);
            }
            if (ShowYAxisFieldsCaption != c.ShowYAxisFieldsCaption)
            {
                writer.WriteBool("ShowYAxisFieldsCaption", ShowYAxisFieldsCaption);
            }
            if (Style != c.Style)
            {
                writer.WriteStr("Style", Style);
            }
            //            if (MatrixEvenStylePriority != c.MatrixEvenStylePriority)
            //                writer.WriteValue("MatrixEvenStylePriority", MatrixEvenStylePriority);
            if (ModifyResultEvent != c.ModifyResultEvent)
            {
                writer.WriteStr("ModifyResultEvent", ModifyResultEvent);
            }
        }
Пример #2
0
        /// <summary>
        /// Serializes the object.
        /// </summary>
        /// <remarks>
        ///   <para>Do not call this method directly. You should override it if you are
        ///     developing a new component for FastReport.</para>
        ///   <para>This method is called when the object needs to save the state. It may happen
        ///     when:</para>
        ///   <list type="bullet">
        ///     <item>
        ///       <description>saving the report to the file or stream;</description>
        ///     </item>
        ///     <item>
        ///       <description>saving the report to the designer's undo buffer;</description>
        ///     </item>
        ///     <item>
        ///       <description>
        ///                 assigning the object to another object using the
        ///                 <see cref="Assign"/> or <see cref="AssignAll(Base)">AssignAll</see> methods;
        ///             </description>
        ///     </item>
        ///     <item>
        ///       <description>saving the object to the designer's clipboard;</description>
        ///     </item>
        ///     <item>
        ///       <description>saving the object to the preview (when run a
        ///             report).</description>
        ///     </item>
        ///   </list>
        /// </remarks>
        /// <param name="writer">Writer object.</param>
        public virtual void Serialize(FRWriter writer)
        {
            Base c = writer.DiffObject as Base;

            if (writer.SerializeTo != SerializeTo.Preview)
            {
                // in the preview mode we don't need to write ItemName and Name properties. Alias is wriiten instead.
                writer.ItemName = isAncestor &&
                                  (writer.SerializeTo == SerializeTo.Report || writer.SerializeTo == SerializeTo.Undo) ?
                                  "inherited" : ClassName;
                if (Name != "")
                {
                    writer.WriteStr("Name", Name);
                }
                if (Restrictions != c.Restrictions)
                {
                    writer.WriteValue("Restrictions", Restrictions);
                }
                if ((writer.SerializeTo == SerializeTo.Report || writer.SerializeTo == SerializeTo.Undo) &&
                    !IsAncestor && Parent != null && Parent.IsAncestor)
                {
                    writer.WriteInt("ZOrder", ZOrder);
                }
            }
            if (writer.SaveChildren)
            {
                foreach (Base child in ChildObjects)
                {
                    writer.Write(child);
                }
            }
        }
Пример #3
0
        //static int i = 0;

        /// <summary>
        /// Assigns values from another source.
        /// </summary>
        /// <remarks>
        /// <b>Note:</b> this method is relatively slow because it serializes
        /// an object to the xml and then deserializes it.
        /// </remarks>
        /// <param name="source">Source to assign from.</param>
        public void BaseAssign(Base source)
        {
            bool saveAncestor = source.IsAncestor;

            source.SetAncestor(false);

            try
            {
                using (XmlItem xml = new XmlItem())
                    using (FRWriter writer = new FRWriter(xml))
                        using (FRReader reader = new FRReader(Report, xml))
                        {
                            writer.SaveChildren = false;
                            writer.Write(source, this);
                            reader.Read(this);
                        }

                Alias             = source.Alias;
                OriginalComponent = source.OriginalComponent;
            }
            finally
            {
                source.SetAncestor(saveAncestor);
            }
        }
Пример #4
0
        private Base CloneObjects(Base source, Base parent)
        {
            if (source is ReportComponentBase && !(source as ReportComponentBase).FlagPreviewVisible)
            {
                return(null);
            }

            // create clone object and assign all properties from source
            string baseName = "";
            string objName;



            Base clone = Activator.CreateInstance(source.GetType()) as Base;

            using (XmlItem xml = new XmlItem())
                using (FRWriter writer = new FRWriter(xml))
                    using (FRReader reader = new FRReader(null, xml))
                    {
                        reader.DeserializeFrom = SerializeTo.SourcePages;
                        writer.SaveChildren    = false;
                        writer.SerializeTo     = SerializeTo.SourcePages;
                        writer.Write(source, clone);
                        reader.Read(clone);
                    }
            clone.Name = source.Name;
            clone.OriginalComponent  = source;
            source.OriginalComponent = clone;
            if (clone is ReportComponentBase)
            {
                (clone as ReportComponentBase).AssignPreviewEvents(source);
            }
            // create alias
            objName = "Page" + pages.Count.ToString() + "." + clone.Name;
            if (clone is BandBase)
            {
                baseName = "b";
            }
            else if (clone is PageBase)
            {
                baseName = "page";
                objName  = "Page" + pages.Count.ToString();
            }
            else
            {
                baseName = clone.BaseName[0].ToString().ToLower();
            }

            clone.Alias  = preparedPages.Dictionary.AddUnique(baseName, objName, clone);
            source.Alias = clone.Alias;

            ObjectCollection childObjects = source.ChildObjects;

            foreach (Base c in childObjects)
            {
                CloneObjects(c, clone);
            }
            clone.Parent = parent;
            return(clone);
        }
Пример #5
0
        /// <summary>
        /// Clone table.
        /// For internal use only.
        /// </summary>
        public virtual void Clone()
        {
            XmlItem item = new XmlItem();

            using (FRWriter writer = new FRWriter(item))
            {
                writer.SerializeTo = SerializeTo.Clipboard;
                writer.BlobStore   = new BlobStore(false);
                writer.Write(this);
            }
            using (FRReader reader = new FRReader(Report, item))
            {
                reader.DeserializeFrom = SerializeTo.Clipboard;
                reader.BlobStore       = new BlobStore(false);
                var connection = Activator.CreateInstance(this.GetType()) as DataConnectionBase;
                connection.Parent = this.Parent;
                connection.SetReport(Report);
                reader.Read(connection);
                connection.CreateUniqueName();
                foreach (TableDataSource table in connection.Tables)
                {
                    table.CreateUniqueName();
                }
                Report.Dictionary.AddChild(connection);
            }
        }
Пример #6
0
 /// <inheritdoc/>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = Name;
     foreach (MatrixHeaderDescriptor d in this)
     {
         writer.Write(d);
     }
 }
Пример #7
0
 /// <summary>
 /// Saves the collection to a stream.
 /// </summary>
 /// <param name="stream">Stream to save to.</param>
 public void Save(Stream stream)
 {
     using (FRWriter writer = new FRWriter())
     {
         writer.Write(this);
         writer.Save(stream);
     }
 }
Пример #8
0
 /// <inheritdoc/>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = "Highlight";
     foreach (HighlightCondition c in this)
     {
         writer.Write(c);
     }
 }
Пример #9
0
 /// <inheritdoc/>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = Name;
     foreach (CrossViewCellDescriptor d in this)
     {
         writer.Write(d);
     }
 }
Пример #10
0
 /// <inheritdoc/>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = "Sort";
     foreach (Sort s in this)
     {
         writer.Write(s);
     }
 }
Пример #11
0
 /// <summary>
 /// Serializes the collection.
 /// </summary>
 /// <param name="writer">Writer object.</param>
 /// <remarks>
 /// This method is for internal use only.
 /// </remarks>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = "StyleSheet";
     foreach (StyleCollection s in this)
     {
         writer.Write(s);
     }
 }
Пример #12
0
 /// <inheritdoc/>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = "Formats";
     foreach (FormatBase c in this)
     {
         writer.Write(c);
     }
 }
 /// <summary>
 /// Serializes the collection.
 /// </summary>
 /// <param name="writer">Writer object.</param>
 /// <remarks>
 /// This method is for internal use only.
 /// </remarks>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = "Columns";
     foreach (GridControlColumn c in this)
     {
         writer.Write(c);
     }
 }
Пример #14
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            TextObjectBase c = writer.DiffObject as TextObjectBase;

            base.Serialize(writer);

            if (Text != c.Text)
            {
                writer.WriteStr("Text", Text);
            }
            if (Padding != c.Padding)
            {
                writer.WriteValue("Padding", Padding);
            }
            if (writer.SerializeTo != SerializeTo.Preview)
            {
                if (AllowExpressions != c.AllowExpressions)
                {
                    writer.WriteBool("AllowExpressions", AllowExpressions);
                }
                if (Brackets != c.Brackets)
                {
                    writer.WriteStr("Brackets", Brackets);
                }
                if (HideZeros != c.HideZeros)
                {
                    writer.WriteBool("HideZeros", HideZeros);
                }
                if (HideValue != c.HideValue)
                {
                    writer.WriteStr("HideValue", HideValue);
                }
                if (NullValue != c.NullValue)
                {
                    writer.WriteStr("NullValue", NullValue);
                }
                if (ProcessAt != c.ProcessAt)
                {
                    writer.WriteValue("ProcessAt", ProcessAt);
                }
                if (Duplicates != c.Duplicates)
                {
                    writer.WriteValue("Duplicates", Duplicates);
                }
            }
            if (Editable)
            {
                writer.WriteBool("Editable", Editable);
            }
            if (Formats.Count > 1)
            {
                writer.Write(Formats);
            }
            else
            {
                Format.Serialize(writer, "Format.", c.Format);
            }
        }
Пример #15
0
 public override void Serialize(FRWriter writer)
 {
     writer.ItemName = Name;
     writer.WriteStr("PageType", FPageType.Name);
     foreach (Base c in FObjects)
     {
         writer.Write(c);
     }
 }
Пример #16
0
 private void SaveReport(Stream stream)
 {
     using (FRWriter writer = new FRWriter())
     {
         writer.SerializeTo = SerializeTo.Undo;
         writer.BlobStore   = BlobStore;
         writer.Write(Report);
         writer.Save(stream);
     }
 }
Пример #17
0
        private void SaveSettings()
        {
            XmlItem root = Config.Root.FindItem("Preview").FindItem("Exports").FindItem(ClassName);

            using (FRWriter writer = new FRWriter(root))
            {
                root.Clear();
                writer.Write(this);
            }
        }
Пример #18
0
 public void Save(XmlItem rootItem)
 {
     rootItem.Clear();
     for (int i = 0; i < pages.Count; i++)
     {
         using (FRWriter writer = new FRWriter(rootItem.Add()))
         {
             writer.Write(pages[i]);
         }
     }
 }
Пример #19
0
 /// <inheritdoc/>
 public void Serialize(FRWriter writer)
 {
     writer.ItemName = "Styles";
     if (!String.IsNullOrEmpty(Name))
     {
         writer.WriteStr("Name", Name);
     }
     foreach (Style s in this)
     {
         writer.Write(s);
     }
 }
Пример #20
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            writer.ItemName = ClassName;
            ObjectCollection childObjects = ChildObjects;

            foreach (Base c in childObjects)
            {
                if (c is Parameter || c is Total || (c is DataComponentBase && (c as DataComponentBase).Enabled))
                {
                    writer.Write(c);
                }
            }
        }
Пример #21
0
 private void UpdateUnlimitedPage(Base obj, XmlItem item)
 {
     item.Clear();
     using (FRWriter writer = new FRWriter(item))
     {
         writer.SerializeTo  = SerializeTo.Preview;
         writer.SaveChildren = false;
         writer.BlobStore    = preparedPages.BlobStore;
         writer.Write(obj);
     }
     foreach (Base child in obj.ChildObjects)
     {
         UpdateUnlimitedPage(child, item.Add());
     }
 }
Пример #22
0
            public void Serialize(FRWriter writer)
            {
                List <string> savedConnections = new List <string>();

                writer.ItemName = "LastConnections";
                foreach (DataConnectionBase connection in FConnections)
                {
                    if (savedConnections.IndexOf(connection.GetConnectionId()) == -1)
                    {
                        writer.SaveChildren = false;
                        writer.Write(connection);
                        savedConnections.Add(connection.GetConnectionId());
                    }
                }
            }
Пример #23
0
        private void Done()
        {
            if (DialogResult == DialogResult.OK)
            {
                Connection.Name = tbConnName.Text;

                // enable items that we have checked in the table tree
                foreach (TreeNode tableNode in tvTables.Nodes)
                {
                    TableDataSource table = tableNode.Tag as TableDataSource;
                    if (table != null)
                    {
                        table.Enabled = tableNode.Checked;

                        foreach (TreeNode colNode in tableNode.Nodes)
                        {
                            Column column = colNode.Tag as Column;
                            if (column != null)
                            {
                                column.Enabled = colNode.Checked;
                            }
                        }
                    }
                }

                // create relations if any
                Connection.CreateRelations();

                XmlItem root = Config.Root.FindItem("Designer").FindItem("LastConnections");
                using (FRWriter writer = new FRWriter(root))
                {
                    root.Clear();
                    writer.Write(FConnections);
                }
            }

            if (ApplicationConnectionMode)
            {
                // in this mode, we don't have to store connection string in the report
                Connection.ConnectionString = "";
            }
            if (DialogResult == DialogResult.OK || EditMode)
            {
                FConnections.Remove(Connection);
            }
            FConnections.Dispose();
        }
Пример #24
0
        public PreparedPage(ReportPage page, PreparedPages preparedPages)
        {
            FPreparedPages = preparedPages;
            FXmlItem       = new XmlItem();

            // page == null when we load prepared report from a file
            if (page != null)
            {
                using (FRWriter writer = new FRWriter(FXmlItem))
                {
                    writer.SerializeTo  = SerializeTo.Preview;
                    writer.SaveChildren = false;
                    writer.Write(page);
                }

                FPageSize = new SizeF(page.PaperWidth * Units.Millimeters, page.PaperHeight * Units.Millimeters);
            }
        }
Пример #25
0
        public PreparedPage(ReportPage page, PreparedPages preparedPages)
        {
            this.preparedPages = preparedPages;
            xmlItem            = new XmlItem();

            // page == null when we load prepared report from a file
            if (page != null)
            {
                using (FRWriter writer = new FRWriter(xmlItem))
                {
                    writer.SerializeTo  = SerializeTo.Preview;
                    writer.SaveChildren = false;
                    writer.Write(page);
                }

                pageSize = new SizeF(page.WidthInPixels, page.HeightInPixels);
            }
        }
Пример #26
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            TableRow c = writer.DiffObject as TableRow;

            serializingToPreview = writer.SerializeTo == SerializeTo.Preview;
            base.Serialize(writer);

            if (FloatDiff(MinHeight, c.MinHeight))
            {
                writer.WriteFloat("MinHeight", MinHeight);
            }
            if (FloatDiff(MaxHeight, c.MaxHeight))
            {
                writer.WriteFloat("MaxHeight", MaxHeight);
            }
            if (FloatDiff(Height, c.Height))
            {
                writer.WriteFloat("Height", Height);
            }
            if (AutoSize != c.AutoSize)
            {
                writer.WriteBool("AutoSize", AutoSize);
            }
            if (CanBreak != c.CanBreak)
            {
                writer.WriteBool("CanBreak", CanBreak);
            }

            if (Parent is TableResult)
            {
                // write children by itself
                SetFlags(Flags.CanWriteChildren, true);
                writer.SaveChildren = true;

                TableResult table = Parent as TableResult;
                foreach (TableColumn column in table.ColumnsToSerialize)
                {
                    TableCell cell = this[column.Index];
                    writer.Write(cell);
                }
            }
        }
Пример #27
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            TableRow c = writer.DiffObject as TableRow;

            FSerializingToPreview = writer.SerializeTo == SerializeTo.Preview;
            base.Serialize(writer);

            if (FloatDiff(MinHeight, c.MinHeight))
            {
                writer.WriteFloat("MinHeight", MinHeight);
            }
            if (FloatDiff(MaxHeight, c.MaxHeight))
            {
                writer.WriteFloat("MaxHeight", MaxHeight);
            }
            if (FloatDiff(Height, c.Height))
            {
                writer.WriteFloat("Height", Height);
            }
            if (AutoSize != c.AutoSize)
            {
                writer.WriteBool("AutoSize", AutoSize);
            }

            if (Parent is TableResult)
            {
                // write children by itself
                SetFlags(Flags.CanWriteChildren, true);
                writer.SaveChildren = true;

                TableResult table = Parent as TableResult;
                for (int i = 0; i < table.Columns.Count; i++)
                {
                    if (table.Columns[i].Visible)
                    {
                        TableCell cell = this[i];
                        writer.Write(cell);
                    }
                }
            }
        }
Пример #28
0
        private bool DoAdd(Base c, XmlItem item)
        {
            if (c == null)
            {
                return(false);
            }
            ReportEngine engine    = Report.Engine;
            bool         isRunning = Report.IsRunning && engine != null;

            if (c is ReportComponentBase)
            {
                if (isRunning && !engine.CanPrint(c as ReportComponentBase))
                {
                    return(false);
                }
            }

            item = item.Add();
            using (FRWriter writer = new FRWriter(item))
            {
                writer.SerializeTo  = SerializeTo.Preview;
                writer.SaveChildren = false;
                writer.BlobStore    = preparedPages.BlobStore;
                writer.Write(c);
            }
            if (isRunning)
            {
                engine.AddObjectToProcess(c, item);
            }

            if ((c.Flags & Flags.CanWriteChildren) == 0)
            {
                ObjectCollection childObjects = c.ChildObjects;
                foreach (Base obj in childObjects)
                {
                    DoAdd(obj, item);
                }
            }

            return(true);
        }
Пример #29
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            writer.ItemName = ClassName;
            if (Name != "")
            {
                writer.WriteStr("Name", Name);
            }
            if (Restrictions != Restrictions.None)
            {
                writer.WriteValue("Restrictions", Restrictions);
            }
            if (!String.IsNullOrEmpty(ConnectionString))
            {
                writer.WriteStr("ConnectionString", Crypter.EncryptString(ConnectionString));
            }
            if (!String.IsNullOrEmpty(ConnectionStringExpression))
            {
                writer.WriteStr("ConnectionStringExpression", ConnectionStringExpression);
            }
            if (LoginPrompt)
            {
                writer.WriteBool("LoginPrompt", true);
            }
            if (CommandTimeout != 30)
            {
                writer.WriteInt("CommandTimeout", CommandTimeout);
            }

            if (writer.SaveChildren)
            {
                foreach (TableDataSource c in Tables)
                {
                    if (c.Enabled)
                    {
                        writer.Write(c);
                    }
                }
            }
        }
Пример #30
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            if (writer.SerializeTo != SerializeTo.SourcePages)
            {
                writer.Write(Data.Columns);
                writer.Write(Data.Rows);
                writer.Write(Data.Cells);
            }
            else
            {
                RefreshTemplate(true);
            }

            base.Serialize(writer);
            MatrixObject c = writer.DiffObject as MatrixObject;

            if (AutoSize != c.AutoSize)
            {
                writer.WriteBool("AutoSize", AutoSize);
            }
            if (CellsSideBySide != c.CellsSideBySide)
            {
                writer.WriteBool("CellsSideBySide", CellsSideBySide);
            }
            if (KeepCellsSideBySide != c.KeepCellsSideBySide)
            {
                writer.WriteBool("KeepCellsSideBySide", KeepCellsSideBySide);
            }
            if (DataSource != c.DataSource)
            {
                writer.WriteRef("DataSource", DataSource);
            }
            if (Filter != c.Filter)
            {
                writer.WriteStr("Filter", Filter);
            }
            if (ShowTitle != c.ShowTitle)
            {
                writer.WriteBool("ShowTitle", ShowTitle);
            }
            if (Style != c.Style)
            {
                writer.WriteStr("Style", Style);
            }
            if (MatrixEvenStylePriority != c.MatrixEvenStylePriority)
            {
                writer.WriteValue("MatrixEvenStylePriority", MatrixEvenStylePriority);
            }
            if (SplitRows != c.SplitRows)
            {
                writer.WriteValue("SplitRows", SplitRows);
            }
            if (ManualBuildEvent != c.ManualBuildEvent)
            {
                writer.WriteStr("ManualBuildEvent", ManualBuildEvent);
            }
            if (ModifyResultEvent != c.ModifyResultEvent)
            {
                writer.WriteStr("ModifyResultEvent", ModifyResultEvent);
            }
            if (AfterTotalsEvent != c.AfterTotalsEvent)
            {
                writer.WriteStr("AfterTotalsEvent", AfterTotalsEvent);
            }
        }