Example #1
0
        /**
         * Remove the relation to the specified part in this namespace and remove the
         * part, if it is no longer needed and flag is set to true.
         *
         * @param part
         *            The related part, to which the relation shall be Removed.
         * @param RemoveUnusedParts
         *            true, if the part shall be Removed from the namespace if not
         *            needed any longer.
         */
        protected internal bool RemoveRelation(POIXMLDocumentPart part, bool RemoveUnusedParts)
        {
            String id = GetRelationId(part);

            if (id == null)
            {
                // part is not related with this POIXMLDocumentPart
                return(false);
            }
            /* decrement usage counter */
            part.DecrementRelationCounter();
            /* remove namespacepart relationship */
            GetPackagePart().RemoveRelationship(id);
            /* remove POIXMLDocument from relations */
            relations.Remove(id);

            if (RemoveUnusedParts)
            {
                /* if last relation to target part was Removed, delete according target part */
                if (part.GetRelationCounter() == 0)
                {
                    try
                    {
                        part.onDocumentRemove();
                    }
                    catch (IOException e)
                    {
                        throw new POIXMLException(e);
                    }
                    GetPackagePart().Package.RemovePart(part.GetPackagePart());
                }
            }
            return(true);
        }
Example #2
0
        protected bool RemoveRelation(POIXMLDocumentPart part, bool RemoveUnusedParts)
        {
            string relationId = this.GetRelationId(part);

            if (relationId == null)
            {
                return(false);
            }
            part.DecrementRelationCounter();
            this.GetPackagePart().RemoveRelationship(relationId);
            this.relations.Remove(relationId);
            if (RemoveUnusedParts)
            {
                if (part.GetRelationCounter() == 0)
                {
                    try
                    {
                        part.onDocumentRemove();
                    }
                    catch (IOException ex)
                    {
                        throw new POIXMLException((Exception)ex);
                    }
                    this.GetPackagePart().Package.RemovePart(part.GetPackagePart());
                }
            }
            return(true);
        }
Example #3
0
        /**
         * Remove the relation to the specified part in this namespace and remove the
         * part, if it is no longer needed and flag is set to true.
         * 
         * @param part
         *            The related part, to which the relation shall be Removed.
         * @param RemoveUnusedParts
         *            true, if the part shall be Removed from the namespace if not
         *            needed any longer.
         */
        protected bool RemoveRelation(POIXMLDocumentPart part, bool RemoveUnusedParts)
        {
            String id = GetRelationId(part);
            if (id == null)
            {
                // part is not related with this POIXMLDocumentPart
                return false;
            }
            /* decrement usage counter */
            part.DecrementRelationCounter();
            /* remove namespacepart relationship */
            GetPackagePart().RemoveRelationship(id);
            /* remove POIXMLDocument from relations */
            relations.Remove(id);

            if (RemoveUnusedParts)
            {
                /* if last relation to target part was Removed, delete according target part */
                if (part.GetRelationCounter() == 0)
                {
                    try
                    {
                        part.onDocumentRemove();
                    }
                    catch (IOException e)
                    {
                        throw new POIXMLException(e);
                    }
                    GetPackagePart().Package.RemovePart(part.GetPackagePart());
                }
            }
            return true;
        }