示例#1
0
        private void btnSecurity_Click(object sender, EventArgs e)
        {
            AnalyticsListener.SendEventStatistic(Properties.Resources.STR_SECURITY_EVENT);
            if (listViewFiles.Items.Count == 0)
                return;

            PdfSecurityOptions pso = null;
            IBatchCleanController bcc = null;

            WorkbookItem item = null;
            if (listViewFiles.SelectedItems.Count > 0)
            {
                item = listViewFiles.SelectedItems[0].Tag as WorkbookItem;
            }
            else
            {
                item = listViewFiles.Items[0].Tag as WorkbookItem;
            }

            if (item != null)
                pso = item.PdfSecurityOptions;

			if (ConverPDFToPDFA)
			{
				pso = new PdfSecurityOptions();
				pso.ConvertToPDFA = ConverPDFToPDFA;
			}

            PdfSecurityDialog securityDialog = new PdfSecurityDialog(pso);

            bool isProtectInstalled = Workshare.Common.Configuration.EnabledFeatures.SecurityEnabled;
            if (isProtectInstalled && listViewFiles.SelectedItems.Count > 0)
            {
                bcc = BatchCleanFactory.GetInstance();
	            if (bcc != null)
	            {
		            List<string> filesToClean = new List<string>();
		            foreach (ListViewItem lvi in listViewFiles.SelectedItems)
		            {
			            WorkbookItem wi = lvi.Tag as WorkbookItem;
			            filesToClean.Add(wi.TempCopy);
		            }

		            bcc.AddFiles(filesToClean.ToArray(), true);

		            if (pso != null && pso.CleanBeforePdf)
		            {
			            bcc.SetCleaningOptions(pso.CleaningOptions);
		            }
	            }

	            securityDialog.CleanController = bcc;
            }


            if (DialogResult.OK == securityDialog.ShowDialog())
            {
                // Update security options for ALL files (but clean ONLY for those selected :)
                foreach (ListViewItem lvi in listViewFiles.Items)
                {
                    WorkbookItem wi = lvi.Tag as WorkbookItem;
                    CopySecurityInformation(securityDialog.PdfSecurityOptions, wi);
                }

                // updates clean for selected :)
                foreach (ListViewItem lvi in listViewFiles.SelectedItems)
                {
                    WorkbookItem wi = lvi.Tag as WorkbookItem;
                    wi.PdfSecurityOptions.CleanBeforePdf = securityDialog.PdfSecurityOptions.CleanBeforePdf;
                    wi.PdfSecurityOptions.CleaningOptions = securityDialog.PdfSecurityOptions.CleaningOptions;
                }
                m_state.IsModified = true;
            }

        }
示例#2
0
        private bool IsSecurityOptionsModified(PdfSecurityDialog securityDialog)
        {
            PdfSecurityOptions dialogOptions = securityDialog.PdfSecurityOptions;
            if (m_saveInfo != null)
            {
                if (m_saveInfo.CleanBeforePdf == dialogOptions.CleanBeforePdf
                    && m_saveInfo.DisableComments == dialogOptions.DisableComments
                    && m_saveInfo.DisableCopy == dialogOptions.DisableCopy
                    && m_saveInfo.DisableModification == dialogOptions.DisableModification
                    && m_saveInfo.DisablePrinting == dialogOptions.DisablePrinting
                    && m_saveInfo.FullSecurity == dialogOptions.FullSecurity)
                {
                    return false;
                }
            }

            m_state.IsModified = true;
            m_saveInfo = dialogOptions;
            return true;
        }